home *** CD-ROM | disk | FTP | other *** search
- import java.applet.Applet;
- import java.applet.AudioClip;
- import java.awt.Button;
- import java.awt.Choice;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.Graphics;
- import java.awt.Image;
- import java.awt.LayoutManager;
- import java.awt.MediaTracker;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.awt.event.ItemEvent;
- import java.awt.event.ItemListener;
- import java.awt.event.MouseEvent;
- import java.awt.event.MouseListener;
- import java.net.MalformedURLException;
- import java.net.URL;
- import java.net.URLEncoder;
- import java.util.EventObject;
-
- public class ImageViewer extends Applet implements Runnable, ActionListener, MouseListener, ItemListener {
- // $FF: renamed from: wi int
- private int field_0;
- // $FF: renamed from: he int
- private int field_1;
- private Color backCol;
- private int currentImage;
- private Image backImage;
- private String backImageName;
- private Color backColor;
- private Image[] image;
- private String[] imageNames;
- private String[] imageFilesNames;
- private Button buttonPlay;
- private Button buttonStop;
- private Button buttonPrev;
- private Button buttonNext;
- private String playLabel;
- private String stopLabel;
- private String prevLabel;
- private String nextLabel;
- private boolean[] isLoaded;
- private Choice list;
- private boolean loaded;
- private Image buffer;
- // $FF: renamed from: b java.awt.Graphics
- private Graphics field_2;
- private Image fond;
- private Thread thread;
- private int pause;
- private int titleWidth;
- private int titleHeight;
- private int space;
- private String statusBarText;
- private int wiIm;
- private int heIm;
- private boolean isSlide;
- private int pause2;
- private AudioClip sound;
- private boolean loopSound;
- private int autoSlide;
- private boolean isBackImage;
-
- public String getAppletInfo() {
- return "Name: ImageViewer\r\nAuthor: Taiji Software";
- }
-
- public void register() {
- try {
- URL u = new URL("http://www.taijisoftware.com");
- ((Applet)this).getAppletContext().showDocument(u, "_blank");
- } catch (Exception e) {
- System.out.println(e);
- this.stop();
- }
- }
-
- public void init() {
- String codeBase = null;
-
- try {
- codeBase = (new URL(((Applet)this).getCodeBase().toString())).getHost();
- System.out.println("Copyright 1999, 2001 Taiji Software(tm)\nYour domain name is : " + codeBase);
- codeBase = codeBase.toUpperCase();
- } catch (Exception var10) {
- }
-
- if (!((Applet)this).getCodeBase().toString().toUpperCase().startsWith("FILE") || ((Applet)this).getParameter("debug") != null) {
- String regCode = ((Applet)this).getParameter("registration_code");
- if (regCode == null) {
- regCode = ((Applet)this).getParameter("reg_domain");
- if (regCode == null) {
- this.register();
- } else {
- if (regCode.length() == codeBase.length() + 4 && !codeBase.startsWith("WWW.")) {
- codeBase = "WWW." + codeBase;
- } else if (regCode.length() == codeBase.length() - 4 && codeBase.startsWith("WWW.")) {
- codeBase = codeBase.substring(4);
- }
-
- char[] chars = new char[codeBase.length()];
- codeBase.getChars(0, codeBase.length(), chars, 0);
- String key = new String("haricot");
- char[] chars2 = new char[key.length()];
- key.getChars(0, key.length(), chars2, 0);
-
- for(int i = 0; i < codeBase.length(); ++i) {
- int j;
- if (i >= key.length()) {
- j = i - key.length() * (i / key.length());
- } else {
- j = i;
- }
-
- chars[i] += chars2[j];
- chars[i] = (char)(chars[i] - chars[i] / 26 * 26 + 97);
- }
-
- String res = new String(chars);
- if (!res.equalsIgnoreCase(regCode)) {
- this.register();
- }
- }
- } else if (!regCode.equals("settevercsedegnamiaj") && !regCode.equals("8078")) {
- this.register();
- }
- }
-
- this.getParameters();
- ((Container)this).setLayout((LayoutManager)null);
- this.fond = ((Component)this).createImage(this.field_0, this.field_1);
- this.buffer = ((Component)this).createImage(this.field_0, this.field_1);
- this.field_2 = this.buffer.getGraphics();
- if (!this.isBackImage) {
- ((Component)this).setBackground(this.backColor);
- } else {
- this.backImage = ((Applet)this).getImage(((Applet)this).getCodeBase(), this.backImageName);
- MediaTracker tracker = new MediaTracker(this);
- tracker.addImage(this.backImage, 0);
-
- try {
- tracker.waitForAll();
- this.loaded = !tracker.isErrorAny();
- } catch (Exception e) {
- System.err.println(e);
- }
-
- if (!this.loaded) {
- System.out.println("problem while loading background image...");
- this.stop();
- }
- }
-
- ((Component)this).repaint();
- this.buttonPlay = new Button(this.playLabel);
- this.buttonPlay.addActionListener(this);
- ((Container)this).add(this.buttonPlay);
- this.buttonStop = new Button(this.stopLabel);
- this.buttonStop.addActionListener(this);
- ((Container)this).add(this.buttonStop);
- this.buttonNext = new Button(this.nextLabel);
- this.buttonNext.addActionListener(this);
- ((Container)this).add(this.buttonNext);
- this.buttonPrev = new Button(this.prevLabel);
- this.buttonPrev.addActionListener(this);
- ((Container)this).add(this.buttonPrev);
- int maxLength = this.buttonPlay.getPreferredSize().width + this.buttonStop.getPreferredSize().width + this.buttonNext.getPreferredSize().width + this.buttonPrev.getPreferredSize().width;
- int space = (int)((float)(this.field_0 - maxLength) / 7.0F);
- this.list = new Choice();
- this.list.addItemListener(this);
- this.isLoaded = new boolean[this.imageNames.length];
- this.image = new Image[this.imageNames.length];
-
- for(int i = 0; i < this.imageNames.length; ++i) {
- this.list.addItem(this.imageNames[i]);
- this.isLoaded[i] = false;
- }
-
- this.list.select(this.imageNames[0]);
- ((Container)this).add(this.list);
- this.buttonPrev.setBounds(2 * space, this.field_1 - this.list.getPreferredSize().height - this.buttonPrev.getPreferredSize().height - 20, this.buttonPrev.getPreferredSize().width, this.buttonPrev.getPreferredSize().height);
- this.buttonPlay.setBounds(3 * space + this.buttonPrev.getPreferredSize().width, this.field_1 - this.list.getPreferredSize().height - this.buttonPrev.getPreferredSize().height - 20, this.buttonPlay.getPreferredSize().width, this.buttonPlay.getPreferredSize().height);
- this.buttonStop.setBounds(4 * space + this.buttonPrev.getPreferredSize().width + this.buttonPlay.getPreferredSize().width, this.field_1 - this.list.getPreferredSize().height - this.buttonPrev.getPreferredSize().height - 20, this.buttonStop.getPreferredSize().width, this.buttonStop.getPreferredSize().height);
- this.buttonNext.setBounds(5 * space + this.buttonPrev.getPreferredSize().width + this.buttonPlay.getPreferredSize().width + this.buttonStop.getPreferredSize().width, this.field_1 - this.list.getPreferredSize().height - this.buttonPrev.getPreferredSize().height - 20, this.buttonNext.getPreferredSize().width, this.buttonNext.getPreferredSize().height);
- this.list.setBounds((this.field_0 - this.list.getPreferredSize().width) / 2, this.field_1 - this.list.getPreferredSize().height - 10, this.list.getPreferredSize().width, this.list.getPreferredSize().height);
- this.initPaint();
- if (this.sound != null) {
- if (this.loopSound) {
- this.sound.loop();
- } else {
- this.sound.play();
- }
- }
-
- ((Component)this).repaint();
- if (this.autoSlide == 1) {
- this.actionPerformed(new ActionEvent(this.buttonPlay, 1001, "play"));
- }
-
- }
-
- public void getParameters() {
- this.field_0 = ((Component)this).getSize().width;
- this.field_1 = ((Component)this).getSize().height;
- this.backImageName = ((Applet)this).getParameter("background_image");
- if (this.backImageName != null) {
- this.isBackImage = true;
- }
-
- if (this.getColor("background_color") != null) {
- this.backColor = this.getColor("background_color");
- }
-
- String s = ((Applet)this).getParameter("play_label");
- if (s != null) {
- this.playLabel = s;
- }
-
- s = ((Applet)this).getParameter("stop_label");
- if (s != null) {
- this.stopLabel = s;
- }
-
- s = ((Applet)this).getParameter("prev_label");
- if (s != null) {
- this.prevLabel = s;
- }
-
- s = ((Applet)this).getParameter("next_label");
- if (s != null) {
- this.nextLabel = s;
- }
-
- s = ((Applet)this).getParameter("pause2");
- if (s != null) {
- this.pause2 = Integer.parseInt(s);
- }
-
- s = ((Applet)this).getParameter("auto_slide");
- if (s != null) {
- this.autoSlide = Integer.parseInt(s);
- }
-
- s = ((Applet)this).getParameter("status_bar_text");
- if (s != null) {
- this.statusBarText = s;
- }
-
- int n;
- for(n = 1; ((Applet)this).getParameter("image" + Integer.toString(n)) != null; ++n) {
- }
-
- this.imageNames = new String[n - 1];
- this.imageFilesNames = new String[n - 1];
-
- for(int i = 0; i < this.imageNames.length; ++i) {
- this.imageFilesNames[i] = ((Applet)this).getParameter("image" + Integer.toString(i + 1));
- this.imageNames[i] = ((Applet)this).getParameter("image_name" + Integer.toString(i + 1));
- if (this.imageNames[i] == null || this.imageNames[i].equals("")) {
- int P = this.imageFilesNames[i].length();
-
- for(int p = -1; (p = this.imageFilesNames[i].indexOf(".", p + 1)) != -1; P = p) {
- }
-
- this.imageNames[i] = this.imageFilesNames[i].substring(0, P);
- }
- }
-
- s = ((Applet)this).getParameter("sound_name");
- if (s != null) {
- this.sound = ((Applet)this).getAudioClip(((Applet)this).getCodeBase(), s);
- }
-
- s = ((Applet)this).getParameter("loop_sound");
- if (s != null) {
- if (s.equals("yes")) {
- this.loopSound = true;
- return;
- }
-
- this.loopSound = false;
- }
-
- }
-
- private Color getColor(String param) {
- String s = ((Applet)this).getParameter(param);
- if (s != null) {
- if (s.substring(0, 1).equals("#")) {
- s = s.substring(1);
- int i = Integer.parseInt(s, 16);
- return new Color(i);
- } else {
- return null;
- }
- } else {
- return null;
- }
- }
-
- public final void paint(Graphics g) {
- if (!this.isBackImage || this.loaded) {
- this.field_2.drawImage(this.fond, 0, 0, this);
- if (this.wiIm < this.titleWidth && this.heIm < this.titleHeight) {
- this.field_2.drawImage(this.image[this.currentImage], (this.titleWidth - this.wiIm) / 2 + 10, (this.titleHeight - this.heIm) / 2 + this.space, this);
- } else if (this.wiIm > this.titleWidth && this.heIm < this.titleHeight) {
- float rap = (float)this.titleWidth / (float)this.wiIm;
- this.field_2.drawImage(this.image[this.currentImage], 10, (int)(((float)this.titleHeight - (float)this.heIm * rap) / 2.0F) + this.space, this.titleWidth, (int)((float)this.heIm * rap), this);
- } else if (this.wiIm < this.titleWidth && this.heIm > this.titleHeight) {
- float rap = (float)this.titleHeight / (float)this.heIm;
- this.field_2.drawImage(this.image[this.currentImage], (int)(((float)this.titleWidth - (float)this.wiIm * rap) / 2.0F) + 10, this.space, (int)((float)this.wiIm * rap), this.titleHeight, this);
- } else {
- float raph = (float)this.titleHeight / (float)this.heIm;
- float rapw = (float)this.titleWidth / (float)this.wiIm;
- if (raph < rapw) {
- this.field_2.drawImage(this.image[this.currentImage], (int)(((float)this.titleWidth - (float)this.wiIm * raph) / 2.0F) + 10, this.space, (int)((float)this.wiIm * raph), this.titleHeight, this);
- } else {
- this.field_2.drawImage(this.image[this.currentImage], 10, (int)(((float)this.titleHeight - (float)this.heIm * rapw) / 2.0F) + this.space, this.titleWidth, (int)((float)this.heIm * rapw), this);
- }
- }
-
- g.drawImage(this.buffer, 0, 0, this);
- }
- }
-
- public final void update(Graphics g) {
- this.paint(g);
- }
-
- public void run() {
- Thread.currentThread().setPriority(4);
- int pauseSum = 0;
-
- while(true) {
- ((Component)this).repaint();
-
- try {
- Thread.sleep((long)this.pause);
- } catch (InterruptedException var2) {
- }
-
- if (this.isSlide) {
- pauseSum += this.pause;
- }
-
- if (pauseSum > this.pause2) {
- pauseSum = 0;
- this.actionPerformed(new ActionEvent(this.buttonNext, 1001, "next"));
- this.isSlide = true;
- }
- }
- }
-
- public void initPaint() {
- Graphics e = this.fond.getGraphics();
- if (this.isBackImage) {
- int wiIm = this.backImage.getWidth(this);
- int heIm = this.backImage.getHeight(this);
- int w = this.field_0 / wiIm + 1;
- int h = this.field_1 / heIm + 1;
-
- for(int i = 1; i <= h; ++i) {
- for(int j = 1; j <= w; ++j) {
- e.drawImage(this.backImage, (j - 1) * wiIm, (i - 1) * heIm, this);
- }
- }
- } else {
- e.setColor(this.backColor);
- e.fillRect(0, 0, this.field_0, this.field_1);
- }
-
- e.setColor(Color.black);
- this.space = this.buttonPrev.getLocation().y / 12;
- e.fillRect(10, this.space, this.field_0 - 20, 10 * this.space);
- e.dispose();
- this.titleWidth = this.field_0 - 20;
- this.titleHeight = 10 * this.space;
- }
-
- public void actionPerformed(ActionEvent evt) {
- if (((EventObject)evt).getSource() instanceof Button) {
- Button b = (Button)((EventObject)evt).getSource();
- if (b.getLabel().equals(this.playLabel)) {
- this.currentImage = this.list.getSelectedIndex();
- if (!this.isLoaded[this.currentImage]) {
- this.image[this.currentImage] = ((Applet)this).getImage(((Applet)this).getCodeBase(), this.imageFilesNames[this.currentImage]);
- MediaTracker tracker = new MediaTracker(this);
- tracker.addImage(this.image[this.currentImage], 0);
-
- try {
- tracker.waitForAll();
- this.loaded = !tracker.isErrorAny();
- } catch (Exception e) {
- System.err.println(e);
- }
-
- this.isLoaded[this.currentImage] = true;
- }
-
- this.wiIm = this.image[this.currentImage].getWidth(this);
- this.heIm = this.image[this.currentImage].getHeight(this);
- ((Component)this).repaint();
- this.isSlide = true;
- return;
- }
-
- if (b.getLabel().equals(this.stopLabel)) {
- this.isSlide = false;
- return;
- }
-
- if (b.getLabel().equals(this.nextLabel)) {
- if (this.isSlide) {
- this.isSlide = false;
- }
-
- ++this.currentImage;
- if (this.currentImage >= this.imageNames.length) {
- this.currentImage = 0;
- }
-
- this.list.select(this.imageNames[this.currentImage]);
- if (!this.isLoaded[this.currentImage]) {
- this.image[this.currentImage] = ((Applet)this).getImage(((Applet)this).getCodeBase(), this.imageFilesNames[this.currentImage]);
- MediaTracker tracker = new MediaTracker(this);
- tracker.addImage(this.image[this.currentImage], 0);
-
- try {
- tracker.waitForAll();
- this.loaded = !tracker.isErrorAny();
- } catch (Exception e) {
- System.err.println(e);
- }
-
- this.isLoaded[this.currentImage] = true;
- }
-
- this.wiIm = this.image[this.currentImage].getWidth(this);
- this.heIm = this.image[this.currentImage].getHeight(this);
- ((Component)this).repaint();
- return;
- }
-
- if (b.getLabel().equals(this.prevLabel)) {
- if (this.isSlide) {
- this.isSlide = false;
- }
-
- --this.currentImage;
- if (this.currentImage < 0) {
- this.currentImage = this.imageNames.length - 1;
- }
-
- this.list.select(this.imageNames[this.currentImage]);
- if (!this.isLoaded[this.currentImage]) {
- this.image[this.currentImage] = ((Applet)this).getImage(((Applet)this).getCodeBase(), this.imageFilesNames[this.currentImage]);
- MediaTracker tracker = new MediaTracker(this);
- tracker.addImage(this.image[this.currentImage], 0);
-
- try {
- tracker.waitForAll();
- this.loaded = !tracker.isErrorAny();
- } catch (Exception e) {
- System.err.println(e);
- }
-
- this.isLoaded[this.currentImage] = true;
- }
-
- this.wiIm = this.image[this.currentImage].getWidth(this);
- this.heIm = this.image[this.currentImage].getHeight(this);
- ((Component)this).repaint();
- }
- }
-
- }
-
- public void itemStateChanged(ItemEvent e) {
- if (this.isSlide) {
- this.isSlide = false;
- }
-
- this.currentImage = this.list.getSelectedIndex();
- if (!this.isLoaded[this.currentImage]) {
- this.image[this.currentImage] = ((Applet)this).getImage(((Applet)this).getCodeBase(), this.imageFilesNames[this.currentImage]);
- MediaTracker tracker = new MediaTracker(this);
- tracker.addImage(this.image[this.currentImage], 0);
-
- try {
- tracker.waitForAll();
- this.loaded = !tracker.isErrorAny();
- } catch (Exception e2) {
- System.err.println(e2);
- }
-
- this.isLoaded[this.currentImage] = true;
- }
-
- this.wiIm = this.image[this.currentImage].getWidth(this);
- this.heIm = this.image[this.currentImage].getHeight(this);
- ((Component)this).repaint();
- }
-
- public void start() {
- if (this.thread == null) {
- this.thread = new Thread(this);
- this.thread.start();
- }
-
- }
-
- public void stop() {
- if (this.thread != null) {
- this.thread = null;
- }
-
- if (this.sound != null) {
- this.sound.stop();
- }
-
- }
-
- public URL giveURL(String url) {
- try {
- if (url.toUpperCase().startsWith("HTTP")) {
- return new URL(url);
- } else if (url.toUpperCase().startsWith("FTP")) {
- int p = url.indexOf(":");
- int p2 = url.indexOf(":", p + 1);
- if (p2 != -1) {
- url = url.substring(0, p + 3) + URLEncoder.encode(url.substring(p + 3, url.length()));
- }
-
- p = url.indexOf("%40");
- if (p != -1) {
- url = url.substring(0, p) + "@" + url.substring(p + 3, url.length());
- }
-
- return new URL(url);
- } else {
- return new URL(((Applet)this).getCodeBase(), url);
- }
- } catch (MalformedURLException e) {
- System.out.println(e);
- return null;
- }
- }
-
- public ImageViewer() {
- this.backColor = Color.white;
- this.pause = 200;
- this.pause2 = 2000;
- this.playLabel = "Slide on";
- this.stopLabel = "Slide off";
- this.prevLabel = "Prev";
- this.nextLabel = "Next";
- ((Component)this).addMouseListener(this);
- }
-
- public void mouseClicked(MouseEvent e) {
- }
-
- public void mouseEntered(MouseEvent e) {
- if (this.statusBarText != null) {
- ((Applet)this).showStatus(this.statusBarText);
- }
-
- }
-
- public void mouseExited(MouseEvent e) {
- }
-
- public void mousePressed(MouseEvent e) {
- }
-
- public void mouseReleased(MouseEvent e) {
- }
- }
-